package com.cn.wanxi.data.impl;

import com.cn.wanxi.data.CompanyData;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;

public class CompanyImpl implements CompanyData {
    @Override
    public CompanyModel getCompanyModel() {
        String sql = "select * from sys_company where is_show=1";
        ResultSet resultSet = JDBC.query(sql);
        CompanyModel model = null;
        try {
            while (resultSet.next()) {
                model = new CompanyModel();
                model.setName(resultSet.getString("name"));
                model.setEnName(resultSet.getString("enname"));
                model.setAddress(resultSet.getString("address"));
                model.setLogo(resultSet.getString("logo"));
                model.setPhone(resultSet.getString("phone"));
                model.setNet(resultSet.getString("net"));
                model.setEmail(resultSet.getString("email"));
                model.setVersion(resultSet.getString("version"));

            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return model;
    }

    @Override
    public int del(CompanyModel companyModel) {
        return  0;
//                String sql = "delete from sys_company where id=" + id;
//
//        return JDBC.excute(sql);
    }

    @Override
    public int update(CompanyModel companyModel) {
        return 0;
    }
}
